package remoto;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.List;

import dominio.Cliente;
import dominioTO.ClienteTO;
import dominioTO.ProveedorTO;


public class Proxy implements InterfazRemota{
	private static Proxy instancia;
	private InterfazRemota iRemota;
	
	
	public static Proxy getInstancia()
	{
		if(instancia==null)
		{
			instancia = new Proxy();
		}
		return instancia;				
	}
	public Proxy()
	{
		try {
			String location="//localhost/Sistema";
			iRemota =(InterfazRemota) Naming.lookup(location);
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	
	@Override
	public void persistirCliente(List<ClienteTO> list) throws RemoteException {
		// TODO Auto-generated method stub
		iRemota.persistirCliente(list);
	}
	@Override
	public ClienteTO buscarCliente(String cuit) throws RemoteException {
		// TODO Auto-generated method stub
		return iRemota.buscarCliente(cuit);
	}
	@Override
	public void persistirProveedor(List<ProveedorTO> list)
			throws RemoteException {
		// TODO Auto-generated method stub
		iRemota.persistirProveedor(list);
		
	}
	@Override
	public ProveedorTO buscarProveedor(String cuit) throws RemoteException {
		// TODO Auto-generated method stub
		return iRemota.buscarProveedor(cuit);
	}

}
